//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Chart
{
    public class BuiltInUnit : Unit
    {
        public BuiltInUnit()
        {

        }
        public BuiltInUnit(BuiltInUnitValue value)
        {
            Value = value;
        }
        private BuiltInUnitValue _value = BuiltInUnitValue.Thousands;

        public BuiltInUnitValue Value
        {
            get { return _value; }
            set { _value = value; }
        }

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("builtInUnit"))
            {
                Value = c.GetOptionalEnum("val", BuiltInUnitValue.Thousands);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("builtInUnit"))
            {
                c.SetOptionalEnum("val", Value, BuiltInUnitValue.Thousands);
            }
        }
    }
}